package com.jerry.wschat.web.controller;

import com.jerry.wschat.model.User;
import com.jerry.wschat.model.vo.ReturnVO;
import com.jerry.wschat.service.UserService;
import com.jerry.wschat.web.security.MyUserDetails;
import com.jerry.wschat.web.security.UserLogin;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @author Jerry.Wu
 * @description:
 * @date 2018/9/12 19:32
 */
@Api("用户管理")
@RestController
@RequestMapping("/user")
public class UserController extends BaseController<User, Integer> {

    @Autowired
    private UserService mUserService;

    @ApiOperation("获取用户")
    @GetMapping("/get")
    public ReturnVO get(@RequestParam Integer id) {
        User user = mUserService.load(id);
        return ReturnVO.OK(user);
    }

    @GetMapping("/currentUser")
    public ReturnVO currentUser(HttpSession session) {
        UserLogin userLogin = getCurrentUser(session);
        return ReturnVO.OK(userLogin);
    }

}
